import book.Booklist;
import operations.IOperation;
import user.AdminUser;
import user.NormalUser;
import user.User;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 */
public class Main {
    public static User login(){
        System.out.print("请输入你的姓名：");
        Scanner scanner = new Scanner(System.in);
        String userName = scanner.nextLine();
        System.out.println("请输入你的身份：1 -> 管理员 0 -> 普通用户");
        int choice = scanner.nextInt();
        if(choice == 1){
            return new AdminUser(userName);
        }else{
            return new NormalUser(userName);
        }
    }

    public static void main(String[] args) {
        //准备数据
        Booklist booklist = new Booklist();
        //1.登录，得到用户的对象
        User user = login();
        System.out.println("hello " + user.getName() + " 欢迎来到图书小练习");
        //选择要进行的操作
        while(true){
            int choice = user.menu();
            user.getiOperation()[choice].work(booklist);
        }

    }
}
